
<!DOCTYPE HTML>
<html lang="zh-hans" >
<head>
    <meta charset="UTF-8">
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <title>流式布局Wrap、Flow · 《Flutter实战》</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="baidu-site-verification" content="Y34sAqDKUH"/>
    <meta name="theme-color" content="#ffffff">
    <!--<meta name="description" content="">-->
    <meta name="description" content="《Flutter实战》是Flutter中文网（https://flutterchina.club）开源的电子书，旨在帮助开发者系统化的了解并学习Flutter。">
    <meta name="keywords" content="flutter实战,flutter书籍,flutter电子书,flutter中文网 ">
    <meta name="generator" content="GitBook 3.2.3">
    
    <meta name="author" content="wendux 824783146@qq.com">
    
    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/style.css">

    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-search-pro/search.css">
    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-ace/ace.css">
    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-splitter/splitter.css">
    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-toggle-chapters/toggle.css">
    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-prism/prism.css">
    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-donate/plugin.css">
    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-fontsettings/website.css">
    
    
    

    

    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="stack.html" />
    
    
    <link rel="prev" href="flex.html" />
    

    <style>
        .pull-right > i {
            font-size: 25px;
            color: #777 !important;
            cursor: pointer;

        }

        .pull-right > i:hover {
            color: #777 !important;
        }

        body {
            font-size: 15px !important;
        }

        a[href='../todo.html'], a[href='todo.html'] {
            color: #888 !important;
        }

        .copyright {
            text-align: center;
            margin: 80px 16px 30px 16px;
            padding-top: 16px;
            border-top: #eee 1px solid;
            color: grey;
            font-size: .9em;
        }

        .ad {
            color: white;
            text-align: center;
            background: url(https://img.alicdn.com/tfs/TB1Huu7vMmTBuNjy1XbXXaMrVXa-2880-400.png);
            background-size: cover;
            cursor: pointer;
            margin-bottom: 30px;
            padding: 18px
        }

        .ad:hover {
            opacity: .8;
        }
    </style>
</head>
<body>
<!--<div id="ad" style="display: none">-->
    <!--<div class="ad ad0"-->
         <!--onclick="_track('aliyun','https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=8hhi4dts')">-->
        <!--<div style="font-size: 1.3em; padding-right: 120px; position: relative; top: 12px">阿里云新春特惠</div>-->
        <!--<div style="color:orange; font-size: 13px">限时红包 最高￥<span style="font-size: 40px">1888</span></div>-->
    <!--</div>-->
    <!--<div class="ad ad1"-->
         <!--onclick="_track('aliyun-puhui','https://promotion.aliyun.com/ntms/act/qwbk.html?spm=5176.11533457.1089570.10.74e877e33jtaGy&userCode=8hhi4dts')">-->
        <!--<div style="font-size: 1.5em;">阿里云全民云计算-新春特惠</div>-->
        <!--<div style="color:orange; font-size: 18px;padding-top: 4px;">普惠上云，云服务器1核1G仅需293元/年</div>-->
    <!--</div>-->
<!--</div>-->

<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://flutterchina.club" target="_blank" class="custom-link"><div><img height=20 style='position:relative; top:5px; padding-right:5px ' src='https://cdn.jsdelivr.net/gh/flutterchina/website@1.0/images/favicon.png'/> Flutter中文网</div></a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    缘起
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../chapter1/">
            
                <a href="../chapter1/">
            
                    
                    起步
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../chapter1/mobile_development_intro.html">
            
                <a href="../chapter1/mobile_development_intro.html">
            
                    
                    移动开发技术简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../chapter1/flutter_intro.html">
            
                <a href="../chapter1/flutter_intro.html">
            
                    
                    Flutter简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../chapter1/install_flutter.html">
            
                <a href="../chapter1/install_flutter.html">
            
                    
                    搭建Flutter开发环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../chapter1/configuration.html">
            
                <a href="../chapter1/configuration.html">
            
                    
                    常见配置问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../chapter1/dart.html">
            
                <a href="../chapter1/dart.html">
            
                    
                    Dart语言简介
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../chapter2/">
            
                <a href="../chapter2/">
            
                    
                    第一个Flutter应用
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../chapter2/first_flutter_app.html">
            
                <a href="../chapter2/first_flutter_app.html">
            
                    
                    计数器示例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../chapter2/flutter_router.html">
            
                <a href="../chapter2/flutter_router.html">
            
                    
                    路由管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../chapter2/flutter_package_mgr.html">
            
                <a href="../chapter2/flutter_package_mgr.html">
            
                    
                    包管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../chapter2/flutter_assets_mgr.html">
            
                <a href="../chapter2/flutter_assets_mgr.html">
            
                    
                    资源管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../chapter2/flutter_app_debug.html">
            
                <a href="../chapter2/flutter_app_debug.html">
            
                    
                    调试Flutter APP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../chapter2/thread_model_and_error_report.html">
            
                <a href="../chapter2/thread_model_and_error_report.html">
            
                    
                    Dart线程模型及异常捕获
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../chapter3/">
            
                <a href="../chapter3/">
            
                    
                    基础Widgets
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../chapter3/flutter_widget_intro.html">
            
                <a href="../chapter3/flutter_widget_intro.html">
            
                    
                    Widget简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../chapter3/text.html">
            
                <a href="../chapter3/text.html">
            
                    
                    文本、字体样式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../chapter3/buttons.html">
            
                <a href="../chapter3/buttons.html">
            
                    
                    按钮
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../chapter3/img_and_icon.html">
            
                <a href="../chapter3/img_and_icon.html">
            
                    
                    图片和Icon
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../chapter3/radio_and_checkbox.html">
            
                <a href="../chapter3/radio_and_checkbox.html">
            
                    
                    单选框和复选框
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../chapter3/input_and_form.html">
            
                <a href="../chapter3/input_and_form.html">
            
                    
                    输入框和表单
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="./">
            
                <a href="./">
            
                    
                    布局类Widgets
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="intro.html">
            
                <a href="intro.html">
            
                    
                    布局类Widgets简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="row_and_column.html">
            
                <a href="row_and_column.html">
            
                    
                    线性布局Row、Column
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="flex.html">
            
                <a href="flex.html">
            
                    
                    弹性布局Flex
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.5.4" data-path="wrap_and_flow.html">
            
                <a href="wrap_and_flow.html">
            
                    
                    流式布局Wrap、Flow
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="stack.html">
            
                <a href="stack.html">
            
                    
                    层叠布局Stack、Positioned
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../chapter5/">
            
                <a href="../chapter5/">
            
                    
                    容器类Widgets
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../chapter5/padding.html">
            
                <a href="../chapter5/padding.html">
            
                    
                    Padding
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../chapter5/constrainedbox_and_sizebox.html">
            
                <a href="../chapter5/constrainedbox_and_sizebox.html">
            
                    
                    布局限制类容器ConstrainedBox、SizeBox
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../chapter5/decoratedbox.html">
            
                <a href="../chapter5/decoratedbox.html">
            
                    
                    装饰容器DecoratedBox
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../chapter5/transform.html">
            
                <a href="../chapter5/transform.html">
            
                    
                    变换Transform
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../chapter5/container.html">
            
                <a href="../chapter5/container.html">
            
                    
                    Container容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../chapter5/material_scaffold.html">
            
                <a href="../chapter5/material_scaffold.html">
            
                    
                    Scaffold、TabBar、底部导航
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../chapter6/">
            
                <a href="../chapter6/">
            
                    
                    可滚动Widgets
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../chapter6/intro.html">
            
                <a href="../chapter6/intro.html">
            
                    
                    可滚动Widgets简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../chapter6/single_child_scrollview.html">
            
                <a href="../chapter6/single_child_scrollview.html">
            
                    
                    SingleChildScrollView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../chapter6/listview.html">
            
                <a href="../chapter6/listview.html">
            
                    
                    ListView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../chapter6/gridview.html">
            
                <a href="../chapter6/gridview.html">
            
                    
                    GridView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="../chapter6/custom_scrollview.html">
            
                <a href="../chapter6/custom_scrollview.html">
            
                    
                    CustomScrollView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.6" data-path="../chapter6/scroll_controller.html">
            
                <a href="../chapter6/scroll_controller.html">
            
                    
                    滚动监听及控制ScrollController
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../chapter7/">
            
                <a href="../chapter7/">
            
                    
                    功能型Widgets
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../chapter7/willpopscope.html">
            
                <a href="../chapter7/willpopscope.html">
            
                    
                    导航返回拦截-WillPopScope
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../chapter7/inherited_widget.html">
            
                <a href="../chapter7/inherited_widget.html">
            
                    
                    数据共享-InheritedWidget
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../chapter7/theme.html">
            
                <a href="../chapter7/theme.html">
            
                    
                    主题-Theme
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../chapter8/">
            
                <a href="../chapter8/">
            
                    
                    事件处理与通知
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../chapter8/listener.html">
            
                <a href="../chapter8/listener.html">
            
                    
                    原始指针事件处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../chapter8/gesture.html">
            
                <a href="../chapter8/gesture.html">
            
                    
                    手势识别
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../chapter8/eventbus.html">
            
                <a href="../chapter8/eventbus.html">
            
                    
                    全局事件总线
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4" data-path="../chapter8/notification.html">
            
                <a href="../chapter8/notification.html">
            
                    
                    通知Notification
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../chapter9/">
            
                <a href="../chapter9/">
            
                    
                    动画
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../chapter9/intro.html">
            
                <a href="../chapter9/intro.html">
            
                    
                    Flutter动画简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../chapter9/animation_structure.html">
            
                <a href="../chapter9/animation_structure.html">
            
                    
                    动画结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../chapter9/route_transition.html">
            
                <a href="../chapter9/route_transition.html">
            
                    
                    自定义路由过渡动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="../chapter9/hero.html">
            
                <a href="../chapter9/hero.html">
            
                    
                    Hero动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="../chapter9/stagger_animation.html">
            
                <a href="../chapter9/stagger_animation.html">
            
                    
                    交错动画
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../chapter13/">
            
                <a href="../chapter13/">
            
                    
                    自定义Widget
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../chapter13/intro.html">
            
                <a href="../chapter13/intro.html">
            
                    
                    自定义Widget方法简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../chapter13/combine.html">
            
                <a href="../chapter13/combine.html">
            
                    
                    通过组合现有Widget实现
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="../chapter13/turn_box.html">
            
                <a href="../chapter13/turn_box.html">
            
                    
                    实例：TurnBox
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.4" data-path="../chapter13/custom_paint.html">
            
                <a href="../chapter13/custom_paint.html">
            
                    
                    CustomPaint与Canvas
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.5" data-path="../chapter13/gradient_circular_progress_demo.html">
            
                <a href="../chapter13/gradient_circular_progress_demo.html">
            
                    
                    实例：圆形渐变进度条(自绘)
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../chapter10/">
            
                <a href="../chapter10/">
            
                    
                    文件操作与网络请求
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../chapter10/file_operation.html">
            
                <a href="../chapter10/file_operation.html">
            
                    
                    文件操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../chapter10/http.html">
            
                <a href="../chapter10/http.html">
            
                    
                    Http请求-HttpClient
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.3" data-path="../chapter10/dio.html">
            
                <a href="../chapter10/dio.html">
            
                    
                    Http请求-Dio package
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.4" data-path="../chapter10/download_with_chunks.html">
            
                <a href="../chapter10/download_with_chunks.html">
            
                    
                    实例：Http分块下载
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.5" data-path="../chapter10/websocket.html">
            
                <a href="../chapter10/websocket.html">
            
                    
                    WebSocket
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.6" data-path="../chapter10/socket.html">
            
                <a href="../chapter10/socket.html">
            
                    
                    使用Socket API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.7" data-path="../chapter10/json_model.html">
            
                <a href="../chapter10/json_model.html">
            
                    
                    Json转Model
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../chapter11/">
            
                <a href="../chapter11/">
            
                    
                    包与插件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../chapter11/develop_package.html">
            
                <a href="../chapter11/develop_package.html">
            
                    
                    开发package
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../chapter11/platform-channel.html">
            
                <a href="../chapter11/platform-channel.html">
            
                    
                    插件开发：平台通道简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.3" data-path="../chapter11/android_implement.html">
            
                <a href="../chapter11/android_implement.html">
            
                    
                    插件开发：实现Android端API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.4" data-path="../chapter11/ios_implement.html">
            
                <a href="../chapter11/ios_implement.html">
            
                    
                    插件开发：实现IOS端API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.5" data-path="../todo.html">
            
                <a href="../todo.html">
            
                    
                    系统能力调用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../chapter12/">
            
                <a href="../chapter12/">
            
                    
                    国际化
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.14.1" data-path="../chapter12/multi_languages_support.html">
            
                <a href="../chapter12/multi_languages_support.html">
            
                    
                    让App支持多语言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.2" data-path="../chapter12/locallization_implement.html">
            
                <a href="../chapter12/locallization_implement.html">
            
                    
                    实现Localizations
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.3" data-path="../chapter12/intl.html">
            
                <a href="../chapter12/intl.html">
            
                    
                    使用Intl包
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../chapter14/">
            
                <a href="../chapter14/">
            
                    
                    Flutter核心原理
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.15.1" data-path="../chapter14/flutter_ui_system.html">
            
                <a href="../chapter14/flutter_ui_system.html">
            
                    
                    Flutter UI系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.2" data-path="../chapter14/element_buildcontext.html">
            
                <a href="../chapter14/element_buildcontext.html">
            
                    
                    Element和BuildContext
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.3" data-path="../chapter14/render_object.html">
            
                <a href="../chapter14/render_object.html">
            
                    
                    RenderObject与RenderBox
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.4" data-path="../chapter14/flutter_app_startup.html">
            
                <a href="../chapter14/flutter_app_startup.html">
            
                    
                    Flutter从启动到显示
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../todo.html">
            
                <a href="../todo.html">
            
                    
                    Flutter资源汇总
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    
    <a class="btn pull-right" aria-label="GitHub">
        <i class="fa fa-edit" title="编辑本文"></i>
    </a>
    <a class="btn pull-right" aria-label="GitHub" href="https://github.com/flutterchina/flutter-in-action">
        <i class="fa fa-github" title="查看本书开源项目"></i>
    </a>
    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >流式布局Wrap、Flow</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h2 id="&#x6D41;&#x5F0F;&#x5E03;&#x5C40;">&#x6D41;&#x5F0F;&#x5E03;&#x5C40;</h2>
<h3 id="wrap">Wrap</h3>
<p>&#x5728;&#x4ECB;&#x7ECD;Row&#x548C;Colum&#x65F6;&#xFF0C;&#x5982;&#x679C;&#x5B50;widget&#x8D85;&#x51FA;&#x5C4F;&#x5E55;&#x8303;&#x56F4;&#xFF0C;&#x5219;&#x4F1A;&#x62A5;&#x6EA2;&#x51FA;&#x9519;&#x8BEF;&#xFF0C;&#x5982;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token function">Row</span><span class="token punctuation">(</span>
  children<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
    <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;xxx&quot;</span><span class="token operator">*</span><span class="token number">100</span><span class="token punctuation">)</span>
  <span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<p>&#x8FD0;&#x884C;&#xFF1A;</p>
<p><img src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action@1.0/docs/imgs/image-20180905171113290.png" alt="image-20180905171113290"></p>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;&#x53F3;&#x8FB9;&#x6EA2;&#x51FA;&#x90E8;&#x5206;&#x62A5;&#x9519;&#x3002;&#x8FD9;&#x662F;&#x56E0;&#x4E3A;Row&#x9ED8;&#x8BA4;&#x53EA;&#x6709;&#x4E00;&#x884C;&#xFF0C;&#x5982;&#x679C;&#x8D85;&#x51FA;&#x5C4F;&#x5E55;&#x4E0D;&#x4F1A;&#x6298;&#x884C;&#x3002;&#x6211;&#x4EEC;&#x628A;&#x8D85;&#x51FA;&#x5C4F;&#x5E55;&#x663E;&#x793A;&#x8303;&#x56F4;&#x4F1A;&#x81EA;&#x52A8;&#x6298;&#x884C;&#x7684;&#x5E03;&#x5C40;&#x79F0;&#x4E3A;&#x6D41;&#x5F0F;&#x5E03;&#x5C40;&#x3002;Flutter&#x4E2D;&#x901A;&#x8FC7;Wrap&#x548C;Flow&#x6765;&#x652F;&#x6301;&#x6D41;&#x5F0F;&#x5E03;&#x5C40;&#xFF0C;&#x5C06;&#x4E0A;&#x4F8B;&#x4E2D;&#x7684;Row&#x6362;&#x6210;Wrap&#x540E;&#x6EA2;&#x51FA;&#x90E8;&#x5206;&#x5219;&#x4F1A;&#x81EA;&#x52A8;&#x6298;&#x884C;&#x3002;&#x4E0B;&#x9762;&#x662F;Wrap&#x7684;&#x5B9A;&#x4E49;:</p>
<pre class="language-"><code class="lang-dart"><span class="token function">Wrap</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
  <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>direction <span class="token operator">=</span> Axis<span class="token punctuation">.</span>horizontal<span class="token punctuation">,</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>alignment <span class="token operator">=</span> WrapAlignment<span class="token punctuation">.</span>start<span class="token punctuation">,</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>spacing <span class="token operator">=</span> <span class="token number">0.0</span><span class="token punctuation">,</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>runAlignment <span class="token operator">=</span> WrapAlignment<span class="token punctuation">.</span>start<span class="token punctuation">,</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>runSpacing <span class="token operator">=</span> <span class="token number">0.0</span><span class="token punctuation">,</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>crossAxisAlignment <span class="token operator">=</span> WrapCrossAlignment<span class="token punctuation">.</span>start<span class="token punctuation">,</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>textDirection<span class="token punctuation">,</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>verticalDirection <span class="token operator">=</span> VerticalDirection<span class="token punctuation">.</span>down<span class="token punctuation">,</span>
  List<span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span> children <span class="token operator">=</span> <span class="token keyword">const</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span>
</code></pre>
<p>&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x770B;&#x5230;Wrap&#x7684;&#x5F88;&#x591A;&#x5C5E;&#x6027;&#x5728;Row&#xFF08;&#x5305;&#x62EC;Flex&#x548C;Column&#xFF09;&#x4E2D;&#x4E5F;&#x6709;&#xFF0C;&#x5982;direction&#x3001;crossAxisAlignment&#x3001;textDirection&#x3001;verticalDirection&#x7B49;&#xFF0C;&#x8FD9;&#x4E9B;&#x53C2;&#x6570;&#x610F;&#x4E49;&#x662F;&#x76F8;&#x540C;&#x7684;&#xFF0C;&#x6211;&#x4EEC;&#x4E0D;&#x518D;&#x91CD;&#x590D;&#x4ECB;&#x7ECD;&#xFF0C;&#x8BFB;&#x8005;&#x53EF;&#x4EE5;&#x67E5;&#x9605;&#x524D;&#x9762;&#x4ECB;&#x7ECD;Row&#x7684;&#x90E8;&#x5206;&#x3002;&#x8BFB;&#x8005;&#x53EF;&#x4EE5;&#x8BA4;&#x4E3A;Wrap&#x548C;Flex&#xFF08;&#x5305;&#x62EC;Row&#x548C;Column&#xFF09;&#x9664;&#x4E86;&#x8D85;&#x51FA;&#x663E;&#x793A;&#x8303;&#x56F4;&#x540E;Wrap&#x4F1A;&#x6298;&#x884C;&#x5916;&#xFF0C;&#x5176;&#x5B83;&#x884C;&#x4E3A;&#x57FA;&#x672C;&#x76F8;&#x540C;&#x3002;&#x4E0B;&#x9762;&#x6211;&#x4EEC;&#x770B;&#x4E00;&#x4E0B;Wrap&#x7279;&#x6709;&#x7684;&#x51E0;&#x4E2A;&#x5C5E;&#x6027;&#xFF1A;</p>
<ul>
<li>spacing&#xFF1A;&#x4E3B;&#x8F74;&#x65B9;&#x5411;&#x5B50;widget&#x7684;&#x95F4;&#x8DDD;</li>
<li>runSpacing&#xFF1A;&#x7EB5;&#x8F74;&#x65B9;&#x5411;&#x7684;&#x95F4;&#x8DDD;</li>
<li>runAlignment&#xFF1A;&#x7EB5;&#x8F74;&#x65B9;&#x5411;&#x7684;&#x5BF9;&#x9F50;&#x65B9;&#x5F0F;</li>
</ul>
<p>&#x4E0B;&#x9762;&#x770B;&#x4E00;&#x4E2A;&#x793A;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token function">Wrap</span><span class="token punctuation">(</span>
  spacing<span class="token punctuation">:</span> <span class="token number">8.0</span><span class="token punctuation">,</span> <span class="token comment">// &#x4E3B;&#x8F74;(&#x6C34;&#x5E73;)&#x65B9;&#x5411;&#x95F4;&#x8DDD;</span>
  runSpacing<span class="token punctuation">:</span> <span class="token number">4.0</span><span class="token punctuation">,</span> <span class="token comment">// &#x7EB5;&#x8F74;&#xFF08;&#x5782;&#x76F4;&#xFF09;&#x65B9;&#x5411;&#x95F4;&#x8DDD;</span>
  alignment<span class="token punctuation">:</span> WrapAlignment<span class="token punctuation">.</span>center<span class="token punctuation">,</span> <span class="token comment">//&#x6CBF;&#x4E3B;&#x8F74;&#x65B9;&#x5411;&#x5C45;&#x4E2D;</span>
  children<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
    <span class="token keyword">new</span> <span class="token class-name">Chip</span><span class="token punctuation">(</span>
      avatar<span class="token punctuation">:</span> <span class="token keyword">new</span> <span class="token class-name">CircleAvatar</span><span class="token punctuation">(</span>backgroundColor<span class="token punctuation">:</span> Colors<span class="token punctuation">.</span>blue<span class="token punctuation">,</span> child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&apos;A&apos;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
      label<span class="token punctuation">:</span> <span class="token keyword">new</span> <span class="token class-name">Text</span><span class="token punctuation">(</span><span class="token string">&apos;Hamilton&apos;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token keyword">new</span> <span class="token class-name">Chip</span><span class="token punctuation">(</span>
      avatar<span class="token punctuation">:</span> <span class="token keyword">new</span> <span class="token class-name">CircleAvatar</span><span class="token punctuation">(</span>backgroundColor<span class="token punctuation">:</span> Colors<span class="token punctuation">.</span>blue<span class="token punctuation">,</span> child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&apos;M&apos;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
      label<span class="token punctuation">:</span> <span class="token keyword">new</span> <span class="token class-name">Text</span><span class="token punctuation">(</span><span class="token string">&apos;Lafayette&apos;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token keyword">new</span> <span class="token class-name">Chip</span><span class="token punctuation">(</span>
      avatar<span class="token punctuation">:</span> <span class="token keyword">new</span> <span class="token class-name">CircleAvatar</span><span class="token punctuation">(</span>backgroundColor<span class="token punctuation">:</span> Colors<span class="token punctuation">.</span>blue<span class="token punctuation">,</span> child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&apos;H&apos;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
      label<span class="token punctuation">:</span> <span class="token keyword">new</span> <span class="token class-name">Text</span><span class="token punctuation">(</span><span class="token string">&apos;Mulligan&apos;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token keyword">new</span> <span class="token class-name">Chip</span><span class="token punctuation">(</span>
      avatar<span class="token punctuation">:</span> <span class="token keyword">new</span> <span class="token class-name">CircleAvatar</span><span class="token punctuation">(</span>backgroundColor<span class="token punctuation">:</span> Colors<span class="token punctuation">.</span>blue<span class="token punctuation">,</span> child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&apos;J&apos;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
      label<span class="token punctuation">:</span> <span class="token keyword">new</span> <span class="token class-name">Text</span><span class="token punctuation">(</span><span class="token string">&apos;Laurens&apos;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token punctuation">)</span><span class="token punctuation">,</span>
  <span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token punctuation">)</span>
</code></pre>
<p>&#x8FD0;&#x884C;&#x6548;&#x679C;&#xFF1A;</p>
<p><img src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action@1.0/docs/imgs/image-20180905173658950.png" alt="image-20180905173658950"></p>
<h3 id="flow">Flow</h3>
<p>&#x6211;&#x4EEC;&#x4E00;&#x822C;&#x5F88;&#x5C11;&#x4F1A;&#x4F7F;&#x7528;Flow&#xFF0C;&#x56E0;&#x4E3A;&#x5176;&#x8FC7;&#x4E8E;&#x590D;&#x6742;&#xFF0C;&#x9700;&#x8981;&#x81EA;&#x5DF1;&#x5B9E;&#x73B0;&#x5B50;widget&#x7684;&#x4F4D;&#x7F6E;&#x8F6C;&#x6362;&#xFF0C;&#x5728;&#x5F88;&#x591A;&#x573A;&#x666F;&#x4E0B;&#x9996;&#x5148;&#x8981;&#x8003;&#x8651;&#x7684;&#x662F;Wrap&#x662F;&#x5426;&#x6EE1;&#x8DB3;&#x9700;&#x6C42;&#x3002;Flow&#x4E3B;&#x8981;&#x7528;&#x4E8E;&#x4E00;&#x4E9B;&#x9700;&#x8981;&#x81EA;&#x5B9A;&#x4E49;&#x5E03;&#x5C40;&#x7B56;&#x7565;&#x6216;&#x6027;&#x80FD;&#x8981;&#x6C42;&#x8F83;&#x9AD8;(&#x5982;&#x52A8;&#x753B;&#x4E2D;)&#x7684;&#x573A;&#x666F;&#x3002;Flow&#x6709;&#x5982;&#x4E0B;&#x4F18;&#x70B9;&#xFF1A;</p>
<ul>
<li>&#x6027;&#x80FD;&#x597D;&#xFF1B;Flow&#x662F;&#x4E00;&#x4E2A;&#x5BF9;child&#x5C3A;&#x5BF8;&#x4EE5;&#x53CA;&#x4F4D;&#x7F6E;&#x8C03;&#x6574;&#x975E;&#x5E38;&#x9AD8;&#x6548;&#x7684;&#x63A7;&#x4EF6;&#xFF0C;Flow&#x7528;&#x8F6C;&#x6362;&#x77E9;&#x9635;&#xFF08;transformation matrices&#xFF09;&#x5728;&#x5BF9;child&#x8FDB;&#x884C;&#x4F4D;&#x7F6E;&#x8C03;&#x6574;&#x7684;&#x65F6;&#x5019;&#x8FDB;&#x884C;&#x4E86;&#x4F18;&#x5316;&#xFF1A;&#x5728;Flow&#x5B9A;&#x4F4D;&#x8FC7;&#x540E;&#xFF0C;&#x5982;&#x679C;child&#x7684;&#x5C3A;&#x5BF8;&#x6216;&#x8005;&#x4F4D;&#x7F6E;&#x53D1;&#x751F;&#x4E86;&#x53D8;&#x5316;&#xFF0C;&#x5728;FlowDelegate&#x4E2D;&#x7684;<code>paintChildren()</code>&#x65B9;&#x6CD5;&#x4E2D;&#x8C03;&#x7528;<code>context.paintChild</code> &#x8FDB;&#x884C;&#x91CD;&#x7ED8;&#xFF0C;&#x800C;<code>context.paintChild</code>&#x5728;&#x91CD;&#x7ED8;&#x65F6;&#x4F7F;&#x7528;&#x4E86;&#x8F6C;&#x6362;&#x77E9;&#x9635;&#xFF08;transformation matrices&#xFF09;&#xFF0C;&#x5E76;&#x6CA1;&#x6709;&#x5B9E;&#x9645;&#x8C03;&#x6574;Widget&#x4F4D;&#x7F6E;&#x3002;</li>
<li>&#x7075;&#x6D3B;&#xFF1B;&#x7531;&#x4E8E;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x81EA;&#x5DF1;&#x5B9E;&#x73B0;FlowDelegate&#x7684;<code>paintChildren()</code>&#x65B9;&#x6CD5;&#xFF0C;&#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x81EA;&#x5DF1;&#x8BA1;&#x7B97;&#x6BCF;&#x4E00;&#x4E2A;widget&#x7684;&#x4F4D;&#x7F6E;&#xFF0C;&#x56E0;&#x6B64;&#xFF0C;&#x53EF;&#x4EE5;&#x81EA;&#x5B9A;&#x4E49;&#x5E03;&#x5C40;&#x7B56;&#x7565;&#x3002;</li>
</ul>
<p>&#x7F3A;&#x70B9;&#xFF1A;</p>
<ul>
<li>&#x4F7F;&#x7528;&#x590D;&#x6742;.</li>
<li>&#x4E0D;&#x80FD;&#x81EA;&#x9002;&#x5E94;&#x5B50;widget&#x5927;&#x5C0F;&#xFF0C;&#x5FC5;&#x987B;&#x901A;&#x8FC7;&#x6307;&#x5B9A;&#x7236;&#x5BB9;&#x5668;&#x5927;&#x5C0F;&#x6216;&#x5B9E;&#x73B0;TestFlowDelegate&#x7684;<code>getSize</code>&#x8FD4;&#x56DE;&#x56FA;&#x5B9A;&#x5927;&#x5C0F;&#x3002;</li>
</ul>
<p>&#x793A;&#x4F8B;&#xFF1A;</p>
<p>&#x6211;&#x4EEC;&#x5BF9;&#x516D;&#x4E2A;&#x8272;&#x5757;&#x8FDB;&#x884C;&#x81EA;&#x5B9A;&#x4E49;&#x6D41;&#x5F0F;&#x5E03;&#x5C40;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token function">Flow</span><span class="token punctuation">(</span>
  delegate<span class="token punctuation">:</span> <span class="token function">TestFlowDelegate</span><span class="token punctuation">(</span>margin<span class="token punctuation">:</span> EdgeInsets<span class="token punctuation">.</span><span class="token function">all</span><span class="token punctuation">(</span><span class="token number">10.0</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
  children<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
    <span class="token keyword">new</span> <span class="token class-name">Container</span><span class="token punctuation">(</span>width<span class="token punctuation">:</span> <span class="token number">80.0</span><span class="token punctuation">,</span> height<span class="token punctuation">:</span><span class="token number">80.0</span><span class="token punctuation">,</span> color<span class="token punctuation">:</span> Colors<span class="token punctuation">.</span>red<span class="token punctuation">,</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token keyword">new</span> <span class="token class-name">Container</span><span class="token punctuation">(</span>width<span class="token punctuation">:</span> <span class="token number">80.0</span><span class="token punctuation">,</span> height<span class="token punctuation">:</span><span class="token number">80.0</span><span class="token punctuation">,</span> color<span class="token punctuation">:</span> Colors<span class="token punctuation">.</span>green<span class="token punctuation">,</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token keyword">new</span> <span class="token class-name">Container</span><span class="token punctuation">(</span>width<span class="token punctuation">:</span> <span class="token number">80.0</span><span class="token punctuation">,</span> height<span class="token punctuation">:</span><span class="token number">80.0</span><span class="token punctuation">,</span> color<span class="token punctuation">:</span> Colors<span class="token punctuation">.</span>blue<span class="token punctuation">,</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token keyword">new</span> <span class="token class-name">Container</span><span class="token punctuation">(</span>width<span class="token punctuation">:</span> <span class="token number">80.0</span><span class="token punctuation">,</span> height<span class="token punctuation">:</span><span class="token number">80.0</span><span class="token punctuation">,</span>  color<span class="token punctuation">:</span> Colors<span class="token punctuation">.</span>yellow<span class="token punctuation">,</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token keyword">new</span> <span class="token class-name">Container</span><span class="token punctuation">(</span>width<span class="token punctuation">:</span> <span class="token number">80.0</span><span class="token punctuation">,</span> height<span class="token punctuation">:</span><span class="token number">80.0</span><span class="token punctuation">,</span> color<span class="token punctuation">:</span> Colors<span class="token punctuation">.</span>brown<span class="token punctuation">,</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token keyword">new</span> <span class="token class-name">Container</span><span class="token punctuation">(</span>width<span class="token punctuation">:</span> <span class="token number">80.0</span><span class="token punctuation">,</span> height<span class="token punctuation">:</span><span class="token number">80.0</span><span class="token punctuation">,</span>  color<span class="token punctuation">:</span> Colors<span class="token punctuation">.</span>purple<span class="token punctuation">,</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
  <span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token punctuation">)</span>
</code></pre>
<p>&#x5B9E;&#x73B0;TestFlowDelegate:</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">class</span> <span class="token class-name">TestFlowDelegate</span> <span class="token keyword">extends</span> <span class="token class-name">FlowDelegate</span> <span class="token punctuation">{</span>
  EdgeInsets margin <span class="token operator">=</span> EdgeInsets<span class="token punctuation">.</span>zero<span class="token punctuation">;</span>
  <span class="token function">TestFlowDelegate</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>margin<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token metadata symbol">@override</span>
  <span class="token keyword">void</span> <span class="token function">paintChildren</span><span class="token punctuation">(</span>FlowPaintingContext context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">var</span> x <span class="token operator">=</span> margin<span class="token punctuation">.</span>left<span class="token punctuation">;</span>
    <span class="token keyword">var</span> y <span class="token operator">=</span> margin<span class="token punctuation">.</span>top<span class="token punctuation">;</span>
    <span class="token comment">//&#x8BA1;&#x7B97;&#x6BCF;&#x4E00;&#x4E2A;&#x5B50;widget&#x7684;&#x4F4D;&#x7F6E;  </span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span>int i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> context<span class="token punctuation">.</span>childCount<span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">var</span> w <span class="token operator">=</span> context<span class="token punctuation">.</span><span class="token function">getChildSize</span><span class="token punctuation">(</span>i<span class="token punctuation">)</span><span class="token punctuation">.</span>width <span class="token operator">+</span> x <span class="token operator">+</span> margin<span class="token punctuation">.</span>right<span class="token punctuation">;</span>
      <span class="token keyword">if</span> <span class="token punctuation">(</span>w <span class="token operator">&lt;</span> context<span class="token punctuation">.</span>size<span class="token punctuation">.</span>width<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        context<span class="token punctuation">.</span><span class="token function">paintChild</span><span class="token punctuation">(</span>i<span class="token punctuation">,</span>
            transform<span class="token punctuation">:</span> <span class="token keyword">new</span> <span class="token class-name">Matrix4<span class="token punctuation">.</span>translationValues</span><span class="token punctuation">(</span>
                x<span class="token punctuation">,</span> y<span class="token punctuation">,</span> <span class="token number">0.0</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        x <span class="token operator">=</span> w <span class="token operator">+</span> margin<span class="token punctuation">.</span>left<span class="token punctuation">;</span>
      <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
        x <span class="token operator">=</span> margin<span class="token punctuation">.</span>left<span class="token punctuation">;</span>
        y <span class="token operator">+=</span> context<span class="token punctuation">.</span><span class="token function">getChildSize</span><span class="token punctuation">(</span>i<span class="token punctuation">)</span><span class="token punctuation">.</span>height <span class="token operator">+</span> margin<span class="token punctuation">.</span>top <span class="token operator">+</span> margin<span class="token punctuation">.</span>bottom<span class="token punctuation">;</span>
        <span class="token comment">//&#x7ED8;&#x5236;&#x5B50;widget(&#x6709;&#x4F18;&#x5316;)  </span>
        context<span class="token punctuation">.</span><span class="token function">paintChild</span><span class="token punctuation">(</span>i<span class="token punctuation">,</span>
            transform<span class="token punctuation">:</span> <span class="token keyword">new</span> <span class="token class-name">Matrix4<span class="token punctuation">.</span>translationValues</span><span class="token punctuation">(</span>
                x<span class="token punctuation">,</span> y<span class="token punctuation">,</span> <span class="token number">0.0</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
         x <span class="token operator">+=</span> context<span class="token punctuation">.</span><span class="token function">getChildSize</span><span class="token punctuation">(</span>i<span class="token punctuation">)</span><span class="token punctuation">.</span>width <span class="token operator">+</span> margin<span class="token punctuation">.</span>left <span class="token operator">+</span> margin<span class="token punctuation">.</span>right<span class="token punctuation">;</span>
      <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>

  <span class="token function">getSize</span><span class="token punctuation">(</span>BoxConstraints constraints<span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token comment">//&#x6307;&#x5B9A;Flow&#x7684;&#x5927;&#x5C0F;  </span>
    <span class="token keyword">return</span> <span class="token function">Size</span><span class="token punctuation">(</span>double<span class="token punctuation">.</span>infinity<span class="token punctuation">,</span><span class="token number">200.0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token metadata symbol">@override</span>
  bool <span class="token function">shouldRepaint</span><span class="token punctuation">(</span>FlowDelegate oldDelegate<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> oldDelegate <span class="token operator">!=</span> <span class="token keyword">this</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x6548;&#x679C;&#xFF1A;</p>
<p><img src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action@1.0/docs/imgs/image-20180905184427501.png" alt="image-20180905184427501"></p>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x6211;&#x4EEC;&#x4E3B;&#x8981;&#x7684;&#x4EFB;&#x52A1;&#x5C31;&#x662F;&#x5B9E;&#x73B0;<code>paintChildren</code>&#xFF0C;&#x5B83;&#x7684;&#x4E3B;&#x8981;&#x4EFB;&#x52A1;&#x662F;&#x786E;&#x5B9A;&#x6BCF;&#x4E2A;&#x5B50;widget&#x4F4D;&#x7F6E;&#x3002;&#x7531;&#x4E8E;Flow&#x4E0D;&#x80FD;&#x81EA;&#x9002;&#x5E94;&#x5B50;widget&#x7684;&#x5927;&#x5C0F;&#xFF0C;&#x6211;&#x4EEC;&#x901A;&#x8FC7;&#x5728;<code>getSize</code>&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x56FA;&#x5B9A;&#x5927;&#x5C0F;&#x6765;&#x6307;&#x5B9A;Flow&#x7684;&#x5927;&#x5C0F;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="flex.html" class="navigation navigation-prev " aria-label="Previous page: 弹性布局Flex">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="stack.html" class="navigation navigation-next " aria-label="Next page: 层叠布局Stack、Positioned">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"流式布局Wrap、Flow","level":"1.5.4","depth":2,"next":{"title":"层叠布局Stack、Positioned","level":"1.5.5","depth":2,"path":"chapter4/stack.md","ref":"chapter4/stack.md","articles":[]},"previous":{"title":"弹性布局Flex","level":"1.5.3","depth":2,"path":"chapter4/flex.md","ref":"chapter4/flex.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","search-pro","ace","splitter","toggle-chapters","prism","donate","-highlight"],"root":"docs","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"lang":{"shell":"bash"}},"ace":{},"splitter":{},"search-pro":{"cutWordLib":"nodejieba","defineWord":["Gitbook Use"]},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"donate":{"alipay":"","alipayText":"支付宝打赏","button":"赏","title":"","wechat":"https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action@1.0.3/docs/imgs/pay.jpeg","wechatText":"微信打赏"},"fontsettings":{"theme":"white","family":"sans","size":2},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"toggle-chapters":{}},"theme":"default","author":"wendux 824783146@qq.com","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"《Flutter实战》","language":"zh-hans","links":{"sharing":{"all":null,"facebook":null,"google":null,"twitter":null,"weibo":null},"sidebar":{"<div><img height=20 style='position:relative; top:5px; padding-right:5px ' src='https://cdn.jsdelivr.net/gh/flutterchina/website@1.0/images/favicon.png'/> Flutter中文网</div>":"https://flutterchina.club"}},"gitbook":"*","description":"记录Gitbook的配置和一些插件的使用"},"file":{"path":"chapter4/wrap_and_flow.md","mtime":"2019-01-15T12:04:04.306Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-14T10:32:57.346Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>



    <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/theme.js"></script>
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-ace/ace/ace.js"></script>
        
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-ace/ace.js"></script>
        
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    


<script>
    var _hmt = _hmt || [];
    $("#bd").remove();
    (function () {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?170231fea4f81697eb046edc1a91fe5b";
        var s = document.getElementsByTagName("script")[0];
        hm.id = "bd"
        s.parentNode.insertBefore(hm, s);
    })();

    function init() {
        var p = location.pathname;
        _hmt.push(['_trackPageview', p]);
        if (p[p.length - 1] === '/') {
            p += "index.md"
        } else {
            p = p.split(".")[0] + ".md";
        }
        p = "https://github.com/flutterchina/flutter-in-action/blob/master/docs" + p;
        $(".pull-right .fa-edit").parent("a").attr("href", p);
        $("table").wrap("<div style='overflow: auto'></div>");
        //百度统计
        var e = /([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gi, r = window.location.href,
            t = document.referrer;
        if (!e.test(r)) {
            var o = "https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif";
            t ? (o += "?r=" + encodeURIComponent(document.referrer), r && (o += "&l=" + r)) : r && (o += "?l=" + r);
            var i = new Image;
            i.src = o
        }
        $(".copyright").remove();
        $("<div class='copyright'> 本书仍在勘误阶段，请勿以任何形式私自传播，作者保留对本书的版权。</div>").appendTo(".page-inner");
    }

    function hookAPI(api, ob, fn) {
        return function () {
            var result = api.apply(ob, [].slice.call(arguments));

            setTimeout(fn, 1000);
            return result;
        }
    }

    function addAD() {
        if (location.href !== 'https://book.flutterchina.club/' && $("#book-search-results .ad").length == 0) {
            var id=Math.ceil(Math.random()*10)%2;
            $(".ad"+id).clone().hide().fadeIn().prependTo("#book-search-results")
            setTimeout(function () {
                $(".body-inner").animate({scrollTop: 0}, 200)
            }, 800);
        }
    }

    function _track(p,url) {
        _hmt.push(['_trackEvent', 'ad', 'click', p]);
        setTimeout(function () {
            location.href = url
        }, 100);
    }

    // setInterval(addAD, 300);

    init();


    if (history.pushState) {
        history.pushState = hookAPI(history.pushState, history, init);
    }

</script>
</body>

</html>

